package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import pojo.EasyUiTreeNode;
import service.ItemCatService;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/item/cat")
public class ItemCatController {

    @Resource
    ItemCatService itemCatService;

    /**
     * 获取EasyUi-Tree商品类目数据
     *
     * @param parentId
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public List<EasyUiTreeNode> getEasyUiTreeNodes(@RequestParam(value="id", defaultValue = "0") long parentId){
        //调用ItemCatServiceImpl的getEasyUiTreeNode方法，获取类目tree数据
        List<EasyUiTreeNode> easyUiTreeNodeList = itemCatService.getEasyUiTreeNode(parentId);
        return easyUiTreeNodeList;
    }

}
